package lab02.test23;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
import java.util.logging.SimpleFormatter;

public class Test {
    public static void main(String[] args) {
        String birthday;

        System.out.println("Please input your birthday");
        Scanner sc=new Scanner(System.in);
        birthday=sc.nextLine();

        /**
         * 2017-11-20->Long time1 毫秒
         * 2017-11-10 ->Long time2 毫秒
         *
         * (time1-time2)/(24*60*60*10000)
         */

        long time1=0;
        long time2=0;

        /**
         * 实例化
         * Student chen=new Student;
         * Study study=new StudentImpl;
         * Calendar calendar=Calendar.getInstance();
         */

        //如何将字符串转换为日期
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");
            Date birthDate = simpleDateFormat.parse(birthday);

            Calendar calendar=Calendar.getInstance();
            calendar.setTime(birthDate);
            time1=calendar.getTimeInMillis();

            Date currentDate=simpleDateFormat.parse("2017-11-10");
            calendar.setTime(currentDate);
            calendar.get(calendar.DAY_OF_WEEK);
          //  calendar.DAY_OF_WEEK
            time2=calendar.getTimeInMillis();

        }catch (ParseException e){

        }finally {
            long days=(time1-time2)/(24*60*60*1000);
            System.out.println("相差天数是："+days);

        }
        // /如何将时间转换为long



    }
}
